home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / misc / emu / amiSPIMsrc.lha / lex.yy.c < prev    next >
C/C++ Source or Header  |  1994-01-19  |  36KB  |  1,520 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.13 90/05/26 17:24:13 vern Exp $
  5.  */
  6.  
  7. #define FLEX_SCANNER
  8.  
  9. #include <stdio.h>
  10.  
  11. #ifdef __STDC__
  12.  
  13. #ifndef DONT_HAVE_STDLIB_H
  14. #include <stdlib.h>
  15. #else
  16. void *malloc( unsigned );
  17. void free( void* );
  18. #endif
  19.  
  20. #define YY_USE_PROTOS
  21. #define YY_USE_CONST
  22. #endif
  23.  
  24.  
  25. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  26. #ifdef c_plusplus
  27. #ifndef __cplusplus
  28. #define __cplusplus
  29. #endif
  30. #endif
  31.  
  32.  
  33. #ifdef __cplusplus
  34.  
  35. #ifndef __STDC__
  36. #include <stdlib.h>
  37. #endif
  38.  
  39. #include <osfcn.h>
  40.  
  41. /* use prototypes in function declarations */
  42. #define YY_USE_PROTOS
  43.  
  44. /* the "const" storage-class-modifier is valid */
  45. #define YY_USE_CONST
  46.  
  47. #endif
  48.  
  49.  
  50. #ifdef __TURBOC__
  51. #define YY_USE_CONST
  52. #endif
  53.  
  54.  
  55. #ifndef YY_USE_CONST
  56. #define const
  57. #endif
  58.  
  59.  
  60. #ifdef YY_USE_PROTOS
  61. #define YY_PROTO(proto) proto
  62. #else
  63. #define YY_PROTO(proto) ()
  64. /* there's no standard place to get these definitions */
  65. char *malloc();
  66. int free();
  67. int read();
  68. #endif
  69.  
  70.  
  71. /* amount of stuff to slurp up with each read */
  72. #ifndef YY_READ_BUF_SIZE
  73. #define YY_READ_BUF_SIZE 8192
  74. #endif
  75.  
  76. /* returned upon end-of-file */
  77. #define YY_END_TOK 0
  78.  
  79. /* copy whatever the last rule matched to the standard output */
  80.  
  81. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  82. /* this used to be an fputs(), but since the string might contain NUL's,
  83.  * we now use fwrite()
  84.  */
  85. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  86.  
  87. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  88.  * is returned in "result".
  89.  */
  90. #define YY_INPUT(buf,result,max_size) \
  91.     if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  92.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  93. #define YY_NULL 0
  94.  
  95. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  96.  * we don't want an extra ';' after the "return" because that will cause
  97.  * some compilers to complain about unreachable statements.
  98.  */
  99. #define yyterminate() return ( YY_NULL )
  100.  
  101. /* report a fatal error */
  102.  
  103. /* The funky do-while is used to turn this macro definition into
  104.  * a single C statement (which needs a semi-colon terminator).
  105.  * This avoids problems with code like:
  106.  *
  107.  *     if ( something_happens )
  108.  *        YY_FATAL_ERROR( "oops, the something happened" );
  109.  *    else
  110.  *        everything_okay();
  111.  *
  112.  * Prior to using the do-while the compiler would get upset at the
  113.  * "else" because it interpreted the "if" statement as being all
  114.  * done when it reached the ';' after the YY_FATAL_ERROR() call.
  115.  */
  116.  
  117. #define YY_FATAL_ERROR(msg) \
  118.     do \
  119.         { \
  120.         (void) fputs( msg, stderr ); \
  121.         (void) putc( '\n', stderr ); \
  122.         exit( 1 ); \
  123.         } \
  124.     while ( 0 )
  125.  
  126. /* default yywrap function - always treat EOF as an EOF */
  127. #define yywrap() 1
  128.  
  129. /* enter a start condition.  This macro really ought to take a parameter,
  130.  * but we do it the disgusting crufty way forced on us by the ()-less
  131.  * definition of BEGIN
  132.  */
  133. #define BEGIN yy_start = 1 + 2 *
  134.  
  135. /* action number for EOF rule of a given start state */
  136. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  137.  
  138. /* special action meaning "start processing a new file" */
  139. #define YY_NEW_FILE \
  140.     do \
  141.         { \
  142.         yy_init_buffer( yy_current_buffer, yyin ); \
  143.         yy_load_buffer_state(); \
  144.         } \
  145.     while ( 0 )
  146.  
  147. /* default declaration of generated scanner - a define so the user can
  148.  * easily add parameters
  149.  */
  150. #define YY_DECL int yylex YY_PROTO(( void )) 
  151.  
  152. /* code executed at the end of each rule */
  153. #define YY_BREAK break;
  154.  
  155. #define YY_END_OF_BUFFER_CHAR 0
  156.  
  157. #ifndef YY_BUF_SIZE
  158. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  159. #endif
  160.  
  161. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  162.  
  163. #define YY_CHAR unsigned char
  164. # line 1 "scanner.l"
  165. #define INITIAL 0
  166. # line 2 "scanner.l"
  167. /* SPIM S20 MIPS simulator.
  168.    Lexical scanner.
  169.    Copyright (C) 1990-1994 by James Larus (larus@cs.wisc.edu).
  170.    ALL RIGHTS RESERVED.
  171.  
  172.    SPIM is distributed under the following conditions:
  173.  
  174.      You may make copies of SPIM for your own use and modify those copies.
  175.  
  176.      All copies of SPIM must retain my name and copyright notice.
  177.  
  178.      You may not sell SPIM or distributed SPIM in conjunction with a
  179.      commerical product or service without the expressed written consent of
  180.      James Larus.
  181.  
  182.    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  183.    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  184.    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  185.    PURPOSE. */
  186.  
  187.  
  188. /* $Header: /home/primost/larus/Software/SPIM/RCS/scanner.l,v 1.37 1994/01/18 03:21:45 larus Exp larus $
  189. */
  190.  
  191.  
  192. #include "spim.h"
  193. #include "spim-utils.h"
  194. #include "inst.h"
  195. #include "sym-tbl.h"
  196. #include "y.tab.h"
  197. #include "parser.h"
  198. #include "scanner.h"
  199.  
  200. #ifndef YY_CHAR
  201. #define YY_CHAR char
  202. #endif
  203.  
  204. /* Exported Variables: */
  205.  
  206. int only_id;
  207. int yylval;        /* Value of token from YYLEX */
  208. int line_no;        /* Line number in input file*/
  209. int y_str_length;    /* Length of Y_STR */
  210.  
  211.  
  212. /* Local Variables: */
  213.  
  214. /* Track which line we are reading and where it began in the buffer. */
  215. static YY_CHAR *line_start = NULL;
  216.  
  217. static double scan_float;    /* Where FP values are kept */
  218.  
  219. static int line_returned = 0;    /* Returned current line yet? */
  220.  
  221.  
  222. /* Local functions: */
  223.  
  224. #ifdef __STDC__
  225. static int check_keyword (YY_CHAR *id, int allow_pseudo_ops);
  226. static YY_CHAR *copy_str (YY_CHAR *str, int chop);
  227. #else
  228. static int check_keyword ();
  229. static YY_CHAR *copy_str ();
  230. #endif
  231.  
  232. # line 71 "scanner.l"
  233.  
  234. /* done after the current pattern has been matched and before the
  235.  * corresponding action - sets up yytext
  236.  */
  237. #define YY_DO_BEFORE_ACTION \
  238.     yytext = yy_bp; \
  239.     yyleng = yy_cp - yy_bp; \
  240.     yy_hold_char = *yy_cp; \
  241.     *yy_cp = '\0'; \
  242.     yy_c_buf_p = yy_cp;
  243.  
  244. #define EOB_ACT_CONTINUE_SCAN 0
  245. #define EOB_ACT_END_OF_FILE 1
  246. #define EOB_ACT_LAST_MATCH 2
  247.  
  248. /* return all but the first 'n' matched characters back to the input stream */
  249. #define yyless(n) \
  250.     do \
  251.         { \
  252.         /* undo effects of setting up yytext */ \
  253.         *yy_cp = yy_hold_char; \
  254.         yy_c_buf_p = yy_cp = yy_bp + n; \
  255.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  256.         } \
  257.     while ( 0 )
  258.  
  259. #define unput(c) yyunput( c, yytext )
  260.  
  261.  
  262. struct yy_buffer_state
  263.     {
  264.     FILE *yy_input_file;
  265.  
  266.     YY_CHAR *yy_ch_buf;        /* input buffer */
  267.     YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  268.  
  269.     /* size of input buffer in bytes, not including room for EOB characters*/
  270.     int yy_buf_size;    
  271.  
  272.     /* number of characters read into yy_ch_buf, not including EOB characters */
  273.     int yy_n_chars;
  274.  
  275.     int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  276. #define EOF_NOT_SEEN 0
  277.     /* "pending" happens when the EOF has been seen but there's still
  278.      * some text process
  279.      */
  280. #define EOF_PENDING 1
  281. #define EOF_DONE 2
  282.     };
  283.  
  284. static YY_BUFFER_STATE yy_current_buffer;
  285.  
  286. /* we provide macros for accessing buffer states in case in the
  287.  * future we want to put the buffer states in a more general
  288.  * "scanner state"
  289.  */
  290. #define YY_CURRENT_BUFFER yy_current_buffer
  291.  
  292.  
  293. /* yy_hold_char holds the character lost when yytext is formed */
  294. static YY_CHAR yy_hold_char;
  295.  
  296. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  297.  
  298.  
  299.  
  300. #ifndef YY_USER_ACTION
  301. #define YY_USER_ACTION
  302. #endif
  303.  
  304. #ifndef YY_USER_INIT
  305. #define YY_USER_INIT
  306. #endif
  307.  
  308. extern YY_CHAR *yytext;
  309. extern int yyleng;
  310. extern FILE *yyin, *yyout;
  311.  
  312. YY_CHAR *yytext;
  313. int yyleng;
  314.  
  315. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  316.  
  317. #define YY_END_OF_BUFFER 16
  318. typedef int yy_state_type;
  319. static const short int yy_accept[42] =
  320.     {   0,
  321.         0,    0,   16,   14,    1,    2,   14,    8,   14,   14,
  322.         9,    9,   10,    9,    6,    3,    3,    2,   11,    0,
  323.        12,    0,    8,    7,    0,    0,    0,    3,    3,    6,
  324.         5,    3,    0,   12,   13,    5,    5,    5,    4,    5,
  325.         0
  326.     } ;
  327.  
  328. static const YY_CHAR yy_ec[256] =
  329.     {   0,
  330.         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  331.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  332.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  333.         1,    2,    1,    4,    5,    6,    1,    1,    7,    8,
  334.         8,    1,    9,   10,   11,   12,    1,   13,   14,   14,
  335.        14,   14,   14,   14,   14,   14,   14,    8,   15,    1,
  336.        16,   17,   18,    1,   19,   19,   19,   19,   19,   19,
  337.        20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
  338.        20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
  339.         1,   21,    1,    1,   20,    1,   19,   19,   19,   19,
  340.  
  341.        22,   19,   20,   20,   20,   20,   20,   20,   20,   20,
  342.        20,   20,   20,   20,   20,   20,   20,   20,   20,   23,
  343.        20,   20,    1,    1,    1,    1,    1,    1,    1,    1,
  344.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  345.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  346.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  347.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  348.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  349.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  350.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  351.  
  352.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  353.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  354.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  355.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  356.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  357.         1,    1,    1,    1,    1
  358.     } ;
  359.  
  360. static const YY_CHAR yy_meta[24] =
  361.     {   0,
  362.         1,    1,    2,    1,    1,    3,    4,    1,    1,    1,
  363.         1,    5,    6,    6,    1,    1,    1,    1,    6,    5,
  364.         1,    6,    5
  365.     } ;
  366.  
  367. static const short int yy_base[48] =
  368.     {   0,
  369.         0,    0,   66,   98,   98,   98,   20,    0,    0,   44,
  370.        98,   12,   98,   14,    0,   30,   17,   98,   98,   28,
  371.        98,   29,    0,    0,   48,   41,   22,   24,   33,    0,
  372.        45,   48,    0,   36,   98,   38,    0,   59,    0,   50,
  373.        98,   73,   79,   83,   89,   91,   33
  374.     } ;
  375.  
  376. static const short int yy_def[48] =
  377.     {   0,
  378.        41,    1,   41,   41,   41,   41,   42,   43,   44,   45,
  379.        41,   41,   41,   41,   46,   41,   41,   41,   41,   42,
  380.        41,   42,   43,   44,   41,   45,   41,   16,   41,   46,
  381.        41,   41,   47,   42,   41,   41,   31,   41,   47,   41,
  382.         0,   41,   41,   41,   41,   41,   41
  383.     } ;
  384.  
  385. static const short int yy_nxt[122] =
  386.     {   0,
  387.         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
  388.        14,   15,   16,   17,   18,   11,   11,   19,   15,   15,
  389.         4,   15,   15,   21,   27,   27,   28,   29,   31,   32,
  390.        32,   21,   34,   31,   27,   27,   29,   29,   39,   21,
  391.        22,   31,   32,   32,   31,   29,   29,   35,   22,   22,
  392.        40,   40,   33,   36,   35,   36,   22,   37,   37,   31,
  393.        32,   32,   40,   40,   26,   41,   38,   36,   41,   36,
  394.        41,   40,   40,   20,   20,   20,   20,   20,   20,   23,
  395.        41,   23,   23,   23,   23,   24,   41,   24,   24,   25,
  396.        25,   25,   41,   25,   25,   30,   30,    3,   41,   41,
  397.  
  398.        41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
  399.        41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
  400.        41
  401.     } ;
  402.  
  403. static const short int yy_chk[122] =
  404.     {   0,
  405.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  406.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  407.         1,    1,    1,    7,   12,   12,   14,   14,   17,   17,
  408.        17,   20,   22,   27,   27,   27,   28,   28,   47,   34,
  409.         7,   16,   16,   16,   29,   29,   29,   26,   20,   22,
  410.        36,   36,   16,   31,   25,   31,   34,   31,   31,   32,
  411.        32,   32,   40,   40,   10,    3,   31,   38,    0,   38,
  412.         0,   38,   38,   42,   42,   42,   42,   42,   42,   43,
  413.         0,   43,   43,   43,   43,   44,    0,   44,   44,   45,
  414.        45,   45,    0,   45,   45,   46,   46,   41,   41,   41,
  415.  
  416.        41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
  417.        41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
  418.        41
  419.     } ;
  420.  
  421. static yy_state_type yy_last_accepting_state;
  422. static YY_CHAR *yy_last_accepting_cpos;
  423.  
  424. /* the intent behind this definition is that it'll catch
  425.  * any uses of REJECT which flex missed
  426.  */
  427. #define REJECT reject_used_but_not_detected
  428. #define yymore() yymore_used_but_not_detected
  429. #define YY_MORE_ADJ 0
  430.  
  431. /* these variables are all declared out here so that section 3 code can
  432.  * manipulate them
  433.  */
  434. /* points to current character in buffer */
  435. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  436. static int yy_init = 1;        /* whether we need to initialize */
  437. static int yy_start = 0;    /* start state number */
  438.  
  439. /* flag which is used to allow yywrap()'s to do buffer switches
  440.  * instead of setting up a fresh yyin.  A bit of a hack ...
  441.  */
  442. static int yy_did_buffer_switch_on_eof;
  443.  
  444. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  445. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  446. static int yy_get_next_buffer YY_PROTO(( void ));
  447. static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  448. void yyrestart YY_PROTO(( FILE *input_file ));
  449. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  450. void yy_load_buffer_state YY_PROTO(( void ));
  451. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  452. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  453. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  454.  
  455. #define yy_new_buffer yy_create_buffer
  456.  
  457. #ifdef __cplusplus
  458. static int yyinput YY_PROTO(( void ));
  459. #else
  460. static int input YY_PROTO(( void ));
  461. #endif
  462.  
  463. YY_DECL
  464.     {
  465.     register yy_state_type yy_current_state;
  466.     register YY_CHAR *yy_cp, *yy_bp;
  467.     register int yy_act;
  468.  
  469.  
  470.  
  471.  
  472.     if ( yy_init )
  473.     {
  474.     YY_USER_INIT;
  475.  
  476.     if ( ! yy_start )
  477.         yy_start = 1;    /* first start state */
  478.  
  479.     if ( ! yyin )
  480.         yyin = stdin;
  481.  
  482.     if ( ! yyout )
  483.         yyout = stdout;
  484.  
  485.     if ( yy_current_buffer )
  486.         yy_init_buffer( yy_current_buffer, yyin );
  487.     else
  488.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  489.  
  490.     yy_load_buffer_state();
  491.  
  492.     yy_init = 0;
  493.     }
  494.  
  495.     while ( 1 )        /* loops until end-of-file is reached */
  496.     {
  497.     yy_cp = yy_c_buf_p;
  498.  
  499.     /* support of yytext */
  500.     *yy_cp = yy_hold_char;
  501.  
  502.     /* yy_bp points to the position in yy_ch_buf of the start of the
  503.      * current run.
  504.      */
  505.     yy_bp = yy_cp;
  506.  
  507.     yy_current_state = yy_start;
  508. yy_match:
  509.     do
  510.         {
  511.         register YY_CHAR yy_c = yy_ec[*yy_cp];
  512.         if ( yy_accept[yy_current_state] )
  513.         {
  514.         yy_last_accepting_state = yy_current_state;
  515.         yy_last_accepting_cpos = yy_cp;
  516.         }
  517.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  518.         {
  519.         yy_current_state = yy_def[yy_current_state];
  520.         if ( yy_current_state >= 42 )
  521.             yy_c = yy_meta[yy_c];
  522.         }
  523.         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  524.         ++yy_cp;
  525.         }
  526.     while ( yy_base[yy_current_state] != 98 );
  527.  
  528. yy_find_action:
  529.     yy_act = yy_accept[yy_current_state];
  530.  
  531.     YY_DO_BEFORE_ACTION;
  532.     YY_USER_ACTION;
  533.  
  534. do_action:    /* this label is used only to access EOF actions */
  535.  
  536.  
  537.     switch ( yy_act )
  538.         {
  539.         case 0: /* must backtrack */
  540.         /* undo the effects of YY_DO_BEFORE_ACTION */
  541.         *yy_cp = yy_hold_char;
  542.         yy_cp = yy_last_accepting_cpos;
  543.         yy_current_state = yy_last_accepting_state;
  544.         goto yy_find_action;
  545.  
  546. case 1:
  547. # line 73 "scanner.l"
  548. {
  549.              if (line_start == NULL) line_start = yytext;
  550.             }
  551.     YY_BREAK
  552. case 2:
  553. # line 78 "scanner.l"
  554. {
  555.             line_no += 1;
  556.             return (Y_NL);
  557.             }
  558.     YY_BREAK
  559. case 3:
  560. # line 84 "scanner.l"
  561. {
  562.              yylval = atoi (yytext);
  563.              if (line_start == NULL) line_start = yytext;
  564.              return (Y_INT);
  565.             }
  566.     YY_BREAK
  567. case 4:
  568. # line 91 "scanner.l"
  569. {
  570.               if (*yytext == '-')
  571.                 {
  572.                   sscanf(yytext+3, "%lx", &yylval);
  573.                   yylval = -yylval;
  574.                 }
  575.               else
  576.                 {
  577.                   sscanf(yytext+2, "%lx", &yylval);
  578.                 }
  579.  
  580.               if (line_start == NULL) line_start = yytext;
  581.               return (Y_INT);
  582.             }
  583.     YY_BREAK
  584. case 5:
  585. # line 107 "scanner.l"
  586. {
  587.               scan_float = atof (yytext);
  588.               yylval = (int) &scan_float;
  589.               if (line_start == NULL) line_start = yytext;
  590.               return (Y_FP);
  591.             }
  592.     YY_BREAK
  593. case 6:
  594. # line 115 "scanner.l"
  595. {
  596.               int token = check_keyword (yytext, !bare_machine);
  597.               label *l;
  598.  
  599.               if (line_start == NULL) line_start = yytext;
  600.               if (!only_id && token != 0)
  601.                 {
  602.                   yylval = token;
  603.                   line_start = yytext;
  604.                   return (token);
  605.                 }
  606.               if (only_id && token != 0)
  607.                 yyerror ("Cannot use opcodes as labels");
  608.  
  609.               if ((l = label_is_defined (yytext)) != NULL
  610.                   && l->const_flag)
  611.                 {
  612.                   yylval =  (int) l->addr;
  613.                   return (Y_INT);
  614.                 }
  615.               else
  616.                 {
  617.                   yylval = (int) str_copy (yytext);
  618.                   return (Y_ID);
  619.                 }
  620.             }
  621.     YY_BREAK
  622. case 7:
  623. # line 143 "scanner.l"
  624. {
  625.               int reg_no = register_name_to_number (yytext + 1);
  626.               if (line_start == NULL) line_start = yytext;
  627.               if (reg_no != -1
  628.                   && *(yytext + 1) == 'f' && *(yytext + 2) != 'p')
  629.                 {
  630.                   yylval = reg_no;
  631.                   return (Y_FP_REG);
  632.                 }
  633.               else if (reg_no < 0 || reg_no > 31)
  634.                 {
  635.                   label *l = label_is_defined (yytext);
  636.  
  637.                   if (l != NULL && l->const_flag)
  638.                 {
  639.                   yylval =  (int) l->addr;
  640.                   return (Y_INT);
  641.                 }
  642.                   else
  643.                 {
  644.                   yylval = (int) str_copy (yytext);
  645.                   return (Y_ID);
  646.                 }
  647.                 }
  648.               else
  649.                 {
  650.                   yylval = reg_no;
  651.                   return (Y_REG);
  652.                 }
  653.             }
  654.     YY_BREAK
  655. case 8:
  656. # line 175 "scanner.l"
  657. {if (line_start == NULL) line_start = yytext;}
  658.     YY_BREAK
  659. case 9:
  660. # line 178 "scanner.l"
  661. {
  662.               if (line_start == NULL) line_start = yytext;
  663.               return (*yytext);
  664.             }
  665.     YY_BREAK
  666. case 10:
  667. # line 184 "scanner.l"
  668. {if (line_start == NULL) line_start = yytext;}
  669.     YY_BREAK
  670. case 11:
  671. # line 186 "scanner.l"
  672. {
  673.               if (line_start == NULL) line_start = yytext;
  674.               yylval = (int) str_copy (yytext);
  675.               /* For top level */
  676.               return (Y_ID);
  677.             }
  678.     YY_BREAK
  679. case 12:
  680. # line 194 "scanner.l"
  681. {
  682.               if (line_start == NULL) line_start = yytext;
  683.               yylval = (int) copy_str (yytext + 1, 1);
  684.               return (Y_STR);
  685.             }
  686.     YY_BREAK
  687. case 13:
  688. # line 200 "scanner.l"
  689. {
  690.               if (line_start == NULL) line_start = yytext;
  691.               yylval = (int) *(yytext + 1);
  692.               return (Y_INT);
  693.             }
  694.     YY_BREAK
  695. case 14:
  696. # line 206 "scanner.l"
  697. {
  698.               if (line_start == NULL) line_start = yytext;
  699.               yyerror ("Unknown character");
  700.             }
  701.     YY_BREAK
  702. case 15:
  703. # line 211 "scanner.l"
  704. ECHO;
  705.     YY_BREAK
  706. case YY_STATE_EOF(INITIAL):
  707.     yyterminate();
  708.  
  709.         case YY_END_OF_BUFFER:
  710.         {
  711.         /* amount of text matched not including the EOB char */
  712.         int yy_amount_of_matched_text = yy_cp - yytext - 1;
  713.  
  714.         /* undo the effects of YY_DO_BEFORE_ACTION */
  715.         *yy_cp = yy_hold_char;
  716.  
  717.         /* note that here we test for yy_c_buf_p "<=" to the position
  718.          * of the first EOB in the buffer, since yy_c_buf_p will
  719.          * already have been incremented past the NUL character
  720.          * (since all states make transitions on EOB to the end-
  721.          * of-buffer state).  Contrast this with the test in yyinput().
  722.          */
  723.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  724.             /* this was really a NUL */
  725.             {
  726.             yy_state_type yy_next_state;
  727.  
  728.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  729.  
  730.             yy_current_state = yy_get_previous_state();
  731.  
  732.             /* okay, we're now positioned to make the
  733.              * NUL transition.  We couldn't have
  734.              * yy_get_previous_state() go ahead and do it
  735.              * for us because it doesn't know how to deal
  736.              * with the possibility of jamming (and we
  737.              * don't want to build jamming into it because
  738.              * then it will run more slowly)
  739.              */
  740.  
  741.             yy_next_state = yy_try_NUL_trans( yy_current_state );
  742.  
  743.             yy_bp = yytext + YY_MORE_ADJ;
  744.  
  745.             if ( yy_next_state )
  746.             {
  747.             /* consume the NUL */
  748.             yy_cp = ++yy_c_buf_p;
  749.             yy_current_state = yy_next_state;
  750.             goto yy_match;
  751.             }
  752.  
  753.             else
  754.             {
  755.             goto yy_find_action;
  756.             }
  757.             }
  758.  
  759.         else switch ( yy_get_next_buffer() )
  760.             {
  761.             case EOB_ACT_END_OF_FILE:
  762.             {
  763.             yy_did_buffer_switch_on_eof = 0;
  764.  
  765.             if ( yywrap() )
  766.                 {
  767.                 /* note: because we've taken care in
  768.                  * yy_get_next_buffer() to have set up yytext,
  769.                  * we can now set up yy_c_buf_p so that if some
  770.                  * total hoser (like flex itself) wants
  771.                  * to call the scanner after we return the
  772.                  * YY_NULL, it'll still work - another YY_NULL
  773.                  * will get returned.
  774.                  */
  775.                 yy_c_buf_p = yytext + YY_MORE_ADJ;
  776.  
  777.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  778.                 goto do_action;
  779.                 }
  780.  
  781.             else
  782.                 {
  783.                 if ( ! yy_did_buffer_switch_on_eof )
  784.                 YY_NEW_FILE;
  785.                 }
  786.             }
  787.             break;
  788.  
  789.             case EOB_ACT_CONTINUE_SCAN:
  790.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  791.  
  792.             yy_current_state = yy_get_previous_state();
  793.  
  794.             yy_cp = yy_c_buf_p;
  795.             yy_bp = yytext + YY_MORE_ADJ;
  796.             goto yy_match;
  797.  
  798.             case EOB_ACT_LAST_MATCH:
  799.             yy_c_buf_p =
  800.                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
  801.  
  802.             yy_current_state = yy_get_previous_state();
  803.  
  804.             yy_cp = yy_c_buf_p;
  805.             yy_bp = yytext + YY_MORE_ADJ;
  806.             goto yy_find_action;
  807.             }
  808.         break;
  809.         }
  810.  
  811.         default:
  812. #ifdef FLEX_DEBUG
  813.         printf( "action # %d\n", yy_act );
  814. #endif
  815.         YY_FATAL_ERROR(
  816.             "fatal flex scanner internal error--no action found" );
  817.         }
  818.     }
  819.     }
  820.  
  821.  
  822. /* yy_get_next_buffer - try to read in a new buffer
  823.  *
  824.  * synopsis
  825.  *     int yy_get_next_buffer();
  826.  *     
  827.  * returns a code representing an action
  828.  *     EOB_ACT_LAST_MATCH - 
  829.  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  830.  *     EOB_ACT_END_OF_FILE - end of file
  831.  */
  832.  
  833. static int yy_get_next_buffer()
  834.  
  835.     {
  836.     register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  837.     register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  838.     register int number_to_move, i;
  839.     int ret_val;
  840.  
  841.     if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  842.     YY_FATAL_ERROR(
  843.         "fatal flex scanner internal error--end of buffer missed" );
  844.  
  845.     /* try to read more data */
  846.  
  847.     /* first move last chars to start of buffer */
  848.     number_to_move = yy_c_buf_p - yytext;
  849.  
  850.     for ( i = 0; i < number_to_move; ++i )
  851.     *(dest++) = *(source++);
  852.  
  853.     if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  854.     /* don't do the read, it's not guaranteed to return an EOF,
  855.      * just force an EOF
  856.      */
  857.     yy_n_chars = 0;
  858.  
  859.     else
  860.     {
  861.     int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  862.  
  863.     if ( num_to_read > YY_READ_BUF_SIZE )
  864.         num_to_read = YY_READ_BUF_SIZE;
  865.  
  866.     else if ( num_to_read <= 0 )
  867.         YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  868.  
  869.     /* read in more data */
  870.     YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  871.           yy_n_chars, num_to_read );
  872.     }
  873.  
  874.     if ( yy_n_chars == 0 )
  875.     {
  876.     if ( number_to_move == 1 )
  877.         {
  878.         ret_val = EOB_ACT_END_OF_FILE;
  879.         yy_current_buffer->yy_eof_status = EOF_DONE;
  880.         }
  881.  
  882.     else
  883.         {
  884.         ret_val = EOB_ACT_LAST_MATCH;
  885.         yy_current_buffer->yy_eof_status = EOF_PENDING;
  886.         }
  887.     }
  888.  
  889.     else
  890.     ret_val = EOB_ACT_CONTINUE_SCAN;
  891.  
  892.     yy_n_chars += number_to_move;
  893.     yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  894.     yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  895.  
  896.     /* yytext begins at the second character in yy_ch_buf; the first
  897.      * character is the one which preceded it before reading in the latest
  898.      * buffer; it needs to be kept around in case it's a newline, so
  899.      * yy_get_previous_state() will have with '^' rules active
  900.      */
  901.  
  902.     yytext = &yy_current_buffer->yy_ch_buf[1];
  903.  
  904.     return ( ret_val );
  905.     }
  906.  
  907.  
  908. /* yy_get_previous_state - get the state just before the EOB char was reached
  909.  *
  910.  * synopsis
  911.  *     yy_state_type yy_get_previous_state();
  912.  */
  913.  
  914. static yy_state_type yy_get_previous_state()
  915.  
  916.     {
  917.     register yy_state_type yy_current_state;
  918.     register YY_CHAR *yy_cp;
  919.  
  920.     yy_current_state = yy_start;
  921.  
  922.     for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  923.     {
  924.     register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  925.     if ( yy_accept[yy_current_state] )
  926.         {
  927.         yy_last_accepting_state = yy_current_state;
  928.         yy_last_accepting_cpos = yy_cp;
  929.         }
  930.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  931.         {
  932.         yy_current_state = yy_def[yy_current_state];
  933.         if ( yy_current_state >= 42 )
  934.         yy_c = yy_meta[yy_c];
  935.         }
  936.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  937.     }
  938.  
  939.     return ( yy_current_state );
  940.     }
  941.  
  942.  
  943. /* yy_try_NUL_trans - try to make a transition on the NUL character
  944.  *
  945.  * synopsis
  946.  *     next_state = yy_try_NUL_trans( current_state );
  947.  */
  948.  
  949. #ifdef YY_USE_PROTOS
  950. static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  951. #else
  952. static yy_state_type yy_try_NUL_trans( yy_current_state )
  953. register yy_state_type yy_current_state;
  954. #endif
  955.  
  956.     {
  957.     register int yy_is_jam;
  958.     register YY_CHAR *yy_cp = yy_c_buf_p;
  959.  
  960.     register YY_CHAR yy_c = 1;
  961.     if ( yy_accept[yy_current_state] )
  962.     {
  963.     yy_last_accepting_state = yy_current_state;
  964.     yy_last_accepting_cpos = yy_cp;
  965.     }
  966.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  967.     {
  968.     yy_current_state = yy_def[yy_current_state];
  969.     if ( yy_current_state >= 42 )
  970.         yy_c = yy_meta[yy_c];
  971.     }
  972.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  973.     yy_is_jam = (yy_base[yy_current_state] == 98);
  974.  
  975.     return ( yy_is_jam ? 0 : yy_current_state );
  976.     }
  977.  
  978.  
  979. #ifdef YY_USE_PROTOS
  980. static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  981. #else
  982. static void yyunput( c, yy_bp )
  983. YY_CHAR c;
  984. register YY_CHAR *yy_bp;
  985. #endif
  986.  
  987.     {
  988.     register YY_CHAR *yy_cp = yy_c_buf_p;
  989.  
  990.     /* undo effects of setting up yytext */
  991.     *yy_cp = yy_hold_char;
  992.  
  993.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  994.     { /* need to shift things up to make room */
  995.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  996.     register YY_CHAR *dest =
  997.         &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  998.     register YY_CHAR *source =
  999.         &yy_current_buffer->yy_ch_buf[number_to_move];
  1000.  
  1001.     while ( source > yy_current_buffer->yy_ch_buf )
  1002.         *--dest = *--source;
  1003.  
  1004.     yy_cp += dest - source;
  1005.     yy_bp += dest - source;
  1006.     yy_n_chars = yy_current_buffer->yy_buf_size;
  1007.  
  1008.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  1009.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  1010.     }
  1011.  
  1012.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  1013.     yy_cp[-2] = '\n';
  1014.  
  1015.     *--yy_cp = c;
  1016.  
  1017.     /* note: the formal parameter *must* be called "yy_bp" for this
  1018.      *       macro to now work correctly
  1019.      */
  1020.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  1021.     }
  1022.  
  1023.  
  1024. #ifdef __cplusplus
  1025. static int yyinput()
  1026. #else
  1027. static int input()
  1028. #endif
  1029.  
  1030.     {
  1031.     int c;
  1032.     YY_CHAR *yy_cp = yy_c_buf_p;
  1033.  
  1034.     *yy_cp = yy_hold_char;
  1035.  
  1036.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1037.     {
  1038.     /* yy_c_buf_p now points to the character we want to return.
  1039.      * If this occurs *before* the EOB characters, then it's a
  1040.      * valid NUL; if not, then we've hit the end of the buffer.
  1041.      */
  1042.     if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1043.         /* this was really a NUL */
  1044.         *yy_c_buf_p = '\0';
  1045.  
  1046.     else
  1047.         { /* need more input */
  1048.         yytext = yy_c_buf_p;
  1049.         ++yy_c_buf_p;
  1050.  
  1051.         switch ( yy_get_next_buffer() )
  1052.         {
  1053.         case EOB_ACT_END_OF_FILE:
  1054.             {
  1055.             if ( yywrap() )
  1056.             {
  1057.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1058.             return ( EOF );
  1059.             }
  1060.  
  1061.             YY_NEW_FILE;
  1062.  
  1063. #ifdef __cplusplus
  1064.             return ( yyinput() );
  1065. #else
  1066.             return ( input() );
  1067. #endif
  1068.             }
  1069.             break;
  1070.  
  1071.         case EOB_ACT_CONTINUE_SCAN:
  1072.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1073.             break;
  1074.  
  1075.         case EOB_ACT_LAST_MATCH:
  1076. #ifdef __cplusplus
  1077.             YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  1078. #else
  1079.             YY_FATAL_ERROR( "unexpected last match in input()" );
  1080. #endif
  1081.         }
  1082.         }
  1083.     }
  1084.  
  1085.     c = *yy_c_buf_p;
  1086.     yy_hold_char = *++yy_c_buf_p;
  1087.  
  1088.     return ( c );
  1089.     }
  1090.  
  1091.  
  1092. #ifdef YY_USE_PROTOS
  1093. void yyrestart( FILE *input_file )
  1094. #else
  1095. void yyrestart( input_file )
  1096. FILE *input_file;
  1097. #endif
  1098.  
  1099.     {
  1100.     yy_init_buffer( yy_current_buffer, input_file );
  1101.     yy_load_buffer_state();
  1102.     }
  1103.  
  1104.  
  1105. #ifdef YY_USE_PROTOS
  1106. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1107. #else
  1108. void yy_switch_to_buffer( new_buffer )
  1109. YY_BUFFER_STATE new_buffer;
  1110. #endif
  1111.  
  1112.     {
  1113.     if ( yy_current_buffer == new_buffer )
  1114.     return;
  1115.  
  1116.     if ( yy_current_buffer )
  1117.     {
  1118.     /* flush out information for old buffer */
  1119.     *yy_c_buf_p = yy_hold_char;
  1120.     yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1121.     yy_current_buffer->yy_n_chars = yy_n_chars;
  1122.     }
  1123.  
  1124.     yy_current_buffer = new_buffer;
  1125.     yy_load_buffer_state();
  1126.  
  1127.     /* we don't actually know whether we did this switch during
  1128.      * EOF (yywrap()) processing, but the only time this flag
  1129.      * is looked at is after yywrap() is called, so it's safe
  1130.      * to go ahead and always set it.
  1131.      */
  1132.     yy_did_buffer_switch_on_eof = 1;
  1133.     }
  1134.  
  1135.  
  1136. #ifdef YY_USE_PROTOS
  1137. void yy_load_buffer_state( void )
  1138. #else
  1139. void yy_load_buffer_state()
  1140. #endif
  1141.  
  1142.     {
  1143.     yy_n_chars = yy_current_buffer->yy_n_chars;
  1144.     yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1145.     yyin = yy_current_buffer->yy_input_file;
  1146.     yy_hold_char = *yy_c_buf_p;
  1147.     }
  1148.  
  1149.  
  1150. #ifdef YY_USE_PROTOS
  1151. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1152. #else
  1153. YY_BUFFER_STATE yy_create_buffer( file, size )
  1154. FILE *file;
  1155. int size;
  1156. #endif
  1157.  
  1158.     {
  1159.     YY_BUFFER_STATE b;
  1160.  
  1161.     b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  1162.  
  1163.     if ( ! b )
  1164.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1165.  
  1166.     b->yy_buf_size = size;
  1167.  
  1168.     /* yy_ch_buf has to be 2 characters longer than the size given because
  1169.      * we need to put in 2 end-of-buffer characters.
  1170.      */
  1171.     b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  1172.  
  1173.     if ( ! b->yy_ch_buf )
  1174.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1175.  
  1176.     yy_init_buffer( b, file );
  1177.  
  1178.     return ( b );
  1179.     }
  1180.  
  1181.  
  1182. #ifdef YY_USE_PROTOS
  1183. void yy_delete_buffer( YY_BUFFER_STATE b )
  1184. #else
  1185. void yy_delete_buffer( b )
  1186. YY_BUFFER_STATE b;
  1187. #endif
  1188.  
  1189.     {
  1190.     if ( b == yy_current_buffer )
  1191.     yy_current_buffer = (YY_BUFFER_STATE) 0;
  1192.  
  1193.     free( (char *) b->yy_ch_buf );
  1194.     free( (char *) b );
  1195.     }
  1196.  
  1197.  
  1198. #ifdef YY_USE_PROTOS
  1199. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  1200. #else
  1201. void yy_init_buffer( b, file )
  1202. YY_BUFFER_STATE b;
  1203. FILE *file;
  1204. #endif
  1205.  
  1206.     {
  1207.     b->yy_input_file = file;
  1208.  
  1209.     /* we put in the '\n' and start reading from [1] so that an
  1210.      * initial match-at-newline will be true.
  1211.      */
  1212.  
  1213.     b->yy_ch_buf[0] = '\n';
  1214.     b->yy_n_chars = 1;
  1215.  
  1216.     /* we always need two end-of-buffer characters.  The first causes
  1217.      * a transition to the end-of-buffer state.  The second causes
  1218.      * a jam in that state.
  1219.      */
  1220.     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1221.     b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  1222.  
  1223.     b->yy_buf_pos = &b->yy_ch_buf[1];
  1224.  
  1225.     b->yy_eof_status = EOF_NOT_SEEN;
  1226.     }
  1227. # line 211 "scanner.l"
  1228.  
  1229.  
  1230.  
  1231.  
  1232. #ifdef __STDC__
  1233. void
  1234. initialize_scanner (FILE *in_file)
  1235. #else
  1236. void
  1237. initialize_scanner (in_file)
  1238.      FILE *in_file;
  1239. #endif
  1240. {
  1241.   yyin = in_file;
  1242. #ifdef FLEX_SCANNER
  1243.   yy_init = 1;
  1244. #endif
  1245.   line_no = 1;
  1246.   line_start = NULL;
  1247.   line_returned = 0;
  1248. }
  1249.  
  1250.  
  1251. #ifdef __STDC__
  1252. void
  1253. scanner_start_line (void)
  1254. #else
  1255. void
  1256. scanner_start_line ()
  1257. #endif
  1258. {
  1259.   line_start = NULL;
  1260.   line_returned = 0;
  1261. }
  1262.  
  1263.  
  1264. #ifndef FLEX_SCANNER
  1265. /* We don't use -ll */
  1266. int yywrap () {return 1;}
  1267. #endif
  1268.  
  1269.  
  1270. /* Return a freshly-allocated copy of STRING with the last CHOP
  1271.    characters removed. */
  1272.  
  1273. #ifdef __STDC__
  1274. static YY_CHAR *
  1275. copy_str (YY_CHAR *str, int chop)
  1276. #else
  1277. static YY_CHAR *
  1278. copy_str (str, chop)
  1279.      YY_CHAR *str;
  1280.      int chop;
  1281. #endif
  1282. {
  1283.   register int new_len = strlen (str) - chop;
  1284.   register YY_CHAR *new_str = (YY_CHAR *) xmalloc (new_len + 1), *n;
  1285.  
  1286.   for (n = new_str; *str != '\0' && new_len > 0; new_len -= 1)
  1287.     if (*str == '\\')
  1288.       switch (*(str + 1))
  1289.     {
  1290.     case 'n':
  1291.       {
  1292.         *n ++ = '\n';
  1293.         str += 2;
  1294.         new_len -= 1;
  1295.         continue;
  1296.       }
  1297.     case 't':
  1298.       {
  1299.         *n ++ = '\t';
  1300.         str += 2;
  1301.         new_len -= 1;
  1302.         continue;
  1303.       }
  1304.     case '"':
  1305.       {
  1306.         *n ++ = '"';
  1307.         str += 2;
  1308.         new_len -= 1;
  1309.         continue;
  1310.       }
  1311.     case 'X':
  1312.       {
  1313.         YY_CHAR c1 = *(str + 2), c2 = *(str + 3);
  1314.         int b = 0;
  1315.  
  1316.         if ('0' <= c1 && c1 <= '9') b = c1 - '0';
  1317.         else if ('A' <= c1 && c1 <= 'F') b = c1 - 'A' + 10;
  1318.         else yyerror ("Bad character in \\X construct in string");
  1319.  
  1320.         b <<= 4;
  1321.         if ('0' <= c2 && c2 <= '9') b += c2 - '0';
  1322.         else if ('A' <= c2 && c2 <= 'F') b += c2 - 'A' + 10;
  1323.         else yyerror ("Bad character in \\X construct in string");
  1324.  
  1325.         *n ++ = (YY_CHAR) b;
  1326.         str += 4;
  1327.         new_len -= 3;
  1328.         continue;
  1329.       }
  1330.     default:
  1331.       {
  1332.         *n ++ = *str ++;
  1333.         continue;
  1334.       }
  1335.     }
  1336.     else
  1337.       *n ++ = *str ++;
  1338.  
  1339.   *n = '\0';
  1340.   y_str_length = n - new_str;
  1341.   return (new_str);
  1342. }
  1343.  
  1344.  
  1345. /* On a parse error, write out the current line and print a caret (^)
  1346.    below the point at which the error occured.    Also, reset the input
  1347.    stream to the begining of the next line. */
  1348.  
  1349. #ifdef __STDC__
  1350. void
  1351. print_erroneous_line (void)
  1352. #else
  1353. void
  1354. print_erroneous_line ()
  1355. #endif
  1356. {
  1357.   int prefix_length = yytext - line_start;
  1358.   int i, c;
  1359.   YY_CHAR buffer[1024], *bp = buffer;
  1360.  
  1361.   if (line_start == NULL) return;
  1362.  
  1363.   error ("      ");
  1364.   c = *(line_start + prefix_length);
  1365.   *(line_start + prefix_length) = '\0';
  1366.   error ("%s", line_start);
  1367.   *(line_start + prefix_length) = c;
  1368.   error ("%s", yytext);
  1369.  
  1370.   /* Flush the rest of the line. */
  1371.   if (*yytext != '\n')
  1372.     {
  1373.       while ((c = input ()) != '\n' && c != EOF)
  1374.     *bp ++ = c;
  1375.       *bp = '\0';
  1376.       error ("%s\n", buffer);
  1377.       if (c == '\n') unput ('\n');
  1378.       line_start = NULL;
  1379.     }
  1380.  
  1381.   error ("      ");
  1382.   for (i = 0; i < prefix_length; i ++) buffer[i] = ' ';
  1383.   buffer[i] = '\0';
  1384.   error ("%s^\n", buffer);
  1385. }
  1386.  
  1387.  
  1388. static inst_info keyword_tbl [] = {
  1389. #undef OP
  1390. #define OP(NAME, OPCODE, TYPE, R_OPCODE) {NAME, OPCODE, TYPE},
  1391. #include "op.h"
  1392. };
  1393.  
  1394.  
  1395. #ifdef __STDC__
  1396. static int
  1397. check_keyword (YY_CHAR *id, int allow_pseudo_ops)
  1398. #else
  1399. static int
  1400. check_keyword (id, allow_pseudo_ops)
  1401.      YY_CHAR *id;
  1402.      int allow_pseudo_ops;
  1403. #endif
  1404. {
  1405.   inst_info *entry =
  1406.     map_string_to_inst_info (keyword_tbl,
  1407.                  sizeof(keyword_tbl) / sizeof (inst_info),
  1408.                  id);
  1409.   if (entry == NULL)
  1410.     return (0);
  1411.   else if (!allow_pseudo_ops && entry->value2 == PSEUDO_OP)
  1412.     return (0);
  1413.   else
  1414.     return (entry->value1);
  1415. }
  1416.  
  1417.  
  1418. static inst_info register_tbl [] = {
  1419.   {"a0", 4, 0},
  1420.   {"a1", 5, 0},
  1421.   {"a2", 6, 0},
  1422.   {"a3", 7, 0},
  1423.   {"at", 1, 0},
  1424.   {"fp", 30, 0},
  1425.   {"gp", 28, 0},
  1426.   {"k0", 26, 0},
  1427.   {"k1", 27, 0},
  1428.   {"kt0", 26, 0},
  1429.   {"kt1", 27, 0},
  1430.   {"ra", 31, 0},
  1431.   {"s0", 16, 0},
  1432.   {"s1", 17, 0},
  1433.   {"s2", 18, 0},
  1434.   {"s3", 19, 0},
  1435.   {"s4", 20, 0},
  1436.   {"s5", 21, 0},
  1437.   {"s6", 22, 0},
  1438.   {"s7", 23, 0},
  1439.   {"s8", 30, 0},
  1440.   {"sp", 29, 0},
  1441.   {"t0", 8, 0},
  1442.   {"t1", 9, 0},
  1443.   {"t2", 10, 0},
  1444.   {"t3", 11, 0},
  1445.   {"t4", 12, 0},
  1446.   {"t5", 13, 0},
  1447.   {"t6", 14, 0},
  1448.   {"t7", 15, 0},
  1449.   {"t8", 24, 0},
  1450.   {"t9", 25, 0},
  1451.   {"v0", 2, 0},
  1452.   {"v1", 3, 0},
  1453.   {"zero", 0, 0}
  1454. };
  1455.  
  1456.  
  1457. #ifdef __STDC__
  1458. int
  1459. register_name_to_number (char *name)
  1460. #else
  1461. int
  1462. register_name_to_number (name)
  1463.      char *name;
  1464. #endif
  1465. {
  1466.   register int c1 = *name, c2 = *(name + 1);
  1467.  
  1468.   if ('0' <= c1 && c1 <= '9'
  1469.       && (c2 == '\0' || (('0' <= c2 && c2 <= '9') && *(name + 2) == '\0')))
  1470.     return (atoi (name));
  1471.   else if (c1 == 'f' && c2 >= '0' && c2 <= '9')
  1472.     return atoi (name + 1);
  1473.   else
  1474.     {
  1475.       inst_info *entry =
  1476.     map_string_to_inst_info (register_tbl,
  1477.                  sizeof (register_tbl) / sizeof (inst_info),
  1478.                  name);
  1479.       if (entry == NULL)
  1480.     return (-1);
  1481.       else
  1482.     return (entry->value1);
  1483.     }
  1484. }
  1485.  
  1486.  
  1487. /* Exactly once, return the current source line, as a printable string
  1488.    with a line number.  Subsequent calls receive NULL instead of the
  1489.    line. */
  1490.  
  1491. #ifdef __STDC__
  1492. char *
  1493. source_line ()
  1494. #else
  1495. char *
  1496. source_line ()
  1497. #endif
  1498. {
  1499.   if (line_returned)
  1500.     return (NULL);
  1501.   else if (line_start == NULL)    /* Error on line */
  1502.     return (NULL);
  1503.   else
  1504.     {
  1505.       YY_CHAR *nl, c;
  1506.       char *r;
  1507.  
  1508.       /* Find end of line: */
  1509.       for (nl = line_start; *nl != '\0' && *nl != '\n'; ) nl += 1;
  1510.       c = *nl;
  1511.       *nl = '\0';
  1512.  
  1513.       r = (char *) xmalloc (nl - line_start + 10);
  1514.       sprintf (r, "%d: %s", line_no, line_start);
  1515.       *nl = c;
  1516.       line_returned = 1;
  1517.       return ((char *) r);
  1518.     }
  1519. }
  1520.